﻿using System;
using System.Collections.Generic;

using System.Text;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Client script include from an embedded resource.
	/// </summary>
	public class ScriptResourceInclude : BaseResourceInclude, IScriptInclude
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		/// <param name="resource"></param>
		/// <param name="type"></param>
		public ScriptResourceInclude(string resource, Type type)
		{
			this.Type = type;
			this.Resource = resource;
		}
		#endregion
		#region EVENTS
		#endregion
		#region PROPS
		public override IncludeType IncludeType
		{
			get { return IncludeType.Script; }
		}
		#endregion
		#region METHODS
		public override string GetClientUrl()
		{
			string content = this.Content;
			if (this.Optimize)
			{
				content = TPage.Current.Obfuscator.Obfuscate(content, TPage.Current.OptimizeScripts);
			}

			CombinedContent cc = CombinedContent.Get(content, "text/javascript");
			return TPage.DoResolveUrl(string.Format("~/TurboResource.axd?k={0}&filename={1}", cc.Key, this.FileName));

		}
		#endregion
		#endregion
		#region INTERNAL
		#region CONST/STATIC
		#endregion
		#region VARS
		#endregion
		#region PROPS
		#endregion
		#region METHODS
		#region INIT
		#endregion
		#region DATA
		#endregion
		#region HANDLERS
		#endregion
		#endregion
		#endregion

	}
}
